package com.battle.service.controller.web;

import com.battle.pojo.param.trainingSolo.*;
import com.battle.pojo.param.trainingSoloDetails.GetTrainingSoloDetailsListParam;
import com.battle.pojo.vo.trainingSolo.*;
import com.battle.pojo.vo.trainingSoloDetails.GetTrainingSoloDetailsListVo;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/单人训练
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/trainingSolo/web")
public class TrainingSoloWebController {

    private final TrainingSoloService service;
    private final TrainingSoloDetailsService detailsService;

    public TrainingSoloWebController(TrainingSoloService service, TrainingSoloDetailsService detailsService) {
        this.service = service;
        this.detailsService = detailsService;
    }


    /**
     * 创建单人训练
     *
     * @param param
     * @return
     */
    @PostMapping("/createTrainingSolo")
    public ApiResult createTrainingSolo(@RequestBody @Valid CreateTrainingSoloParam param) {
        service.createTrainingSolo(param);
        return ApiResult.ok();
    }


    /**
     * 修改单人训练
     *
     * @param param
     */
    @PutMapping("/editTrainingSolo")
    public ApiResult editTrainingSolo(@RequestBody @Valid EditTrainingSoloParam param) {
        service.editTrainingSolo(param);
        return ApiResult.ok();
    }


    /**
     * 获取单人训练详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getTrainingSolo")
    public ApiResult<GetTrainingSoloVo> getTrainingSolo(@RequestParam("id") Long id) {
        GetTrainingSoloVo vo = service.getTrainingSolo(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取队站训练列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getTrainingSoloList")
    public ApiResult<PageResult<GetTrainingSoloListVo>> getTrainingSoloList(@RequestBody GetTrainingSoloListParam param) {
        PageResult<GetTrainingSoloListVo> result = service.getTrainingSoloList(param);
        return ApiResult.ok(result);
    }

    /**
     * 获取人员训练记录
     *
     * @param param
     * @return
     */
    @PostMapping("/getTrainingSoloDetailsList")
    public ApiResult<PageResult<GetTrainingSoloDetailsListVo>> getTrainingSoloDetailsList(@RequestBody GetTrainingSoloDetailsListParam param) {
        PageResult<GetTrainingSoloDetailsListVo> result = detailsService.getTrainingSoloDetailsList(param);
        return ApiResult.ok(result);
    }

    /**
     * 移动端-根据人员id获取训练统计数量
     * @param personId
     * @return
     */
    @GetMapping("/getTrainingNumber")
    public ApiResult<GetTrainingNumberVo> getTrainingNumber(@RequestParam("personId") Long personId) {
        GetTrainingNumberVo vo = service.getTrainingNumber(personId);
        return ApiResult.ok(vo);
    }
}

